//
//  SMRegisterViewController.m
//  ShoppingMall
//
//  Created by Demon on 2018/3/26.
//  Copyright © 2018年 Demon. All rights reserved.
//

#import "SMRegisterViewController.h"

@interface SMRegisterViewController ()
@property (weak, nonatomic) IBOutlet UITextField *telPhonetf;
@property (weak, nonatomic) IBOutlet UITextField *pwdOneTF;
@property (weak, nonatomic) IBOutlet UITextField *twoPhoneTf;

@end

@implementation SMRegisterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
- (IBAction)regiterBtnClick:(id)sender {
    
    if (self.telPhonetf.text.length != 11) {
        [MBProgressHUD showError:@"请正确输入手机号码"];
        return;
    }
    
    if (![self.pwdOneTF.text isEqualToString:self.twoPhoneTf.text]) {
        [MBProgressHUD showError:@"两次密码不一样"];
        return;
    }
    MBProgressHUD *hud = [MBProgressHUD showIndeterminateAndText:self.view text:@"正在注册..."];
    [[YDNetClient sharedInstance] postMethod:@"http://jidianping.com/api/tb/register/regist.php" param:@{@"phonenum":self.telPhonetf.text,@"psw":self.twoPhoneTf.text} success:^(id object) {
        [hud hideAnimated:YES];
        set_userdefault(kUserTelPhone, self.telPhonetf.text);
        set_login_status(YES);
        [self dismissViewControllerAnimated:YES completion:nil];
    } fail:^(NSError *error) {
        [hud hideAnimated:YES];
        [MBProgressHUD showError:@"注册失败"];
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
